package cn.nubia.admin.common.mybatis.service;


import cn.nubia.admin.common.mybatis.bean.OtherBeansRef;
import cn.nubia.admin.common.mybatis.bean.Paged;
import cn.nubia.admin.common.mybatis.dao.BaseDAO;
import cn.nubia.admin.common.mybatis.bean.OtherBeansRef;
import cn.nubia.admin.common.mybatis.bean.Paged;
import cn.nubia.admin.common.mybatis.bean.Query;
import cn.nubia.admin.common.mybatis.dao.BaseDAO;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;

import java.util.List;
import java.util.Map;

/**
 * com.cyou.fz.cms.common.mybatis.service.
 * <p>User:宇翔
 * <p>Date:2014/9/18  11:49
 */
public interface BaseService<T> {
    int count(Query query);

    T insert(T obj);

    T get(Integer id);

    T get(Query query);

    void delete(int id);

    void update(T obj);

    void delete(T obj);

    void removeByQuery(Query query);

    List<T> findAll();

    List<T> findByQuery(Query query);

    Paged<T> findPagedByQuery(Query query);

    BaseDAO<T> getDAO();

    void setApplicationContext(ApplicationContext applicationContext) throws BeansException;

    List<Map<String, Object>> findMapByIds(List<Integer> idList, Class clazz);

    List<Integer> getListMapIds(List<Map<String, Object>> objList, String fieldName);

    boolean isExist(Query query, Integer oid);

    <M> Paged<M> findPageWithBean(Query query, String refIdFieldName, String[] includeNames, Class clazz, Class<M> retClazz);

    <M> Paged<M> findPageWithBeans(Query query, OtherBeansRef[] refs, Class<M> retClazz);


}
